<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
    <script src="/static/component/layui/layui.js"></script>
    <script src="/static/component/pear/pear.js"></script>
</head>

<body class="pear-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form class="layui-form edit-form" method="post" action="">
                    <div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">物品发放</li>
                            <li>测试1</li>
                            <li>测试2</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">

                                <div class="layui-form-item">
                                    <label class="layui-form-label">
                                        上传文件
                                    </label>
                                    <button class="pear-btn pear-btn-primary pear-btn-sm upload-image" type="button">
                                        <i class="fa fa-image">
                                        </i>
                                        上传文件
                                    </button>

                                    <input lay-verify="uploadbg" id="filepath" name="filepath" type="hidden"
                                        value="{$data['bg']??''}" />
                                    <div class="upload-image">
                                        <span>
                                        </span>
                                        <img class="upload-image" src="{$data['bg']??''}" />
                                    </div>

                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">
                                        备注
                                    </label>
                                    <div class="layui-input-block">
                                        <textarea name="desc" class="layui-textarea">{$data['desc']??''}</textarea>
                                    </div>
                                </div>


                            </div>
                            <div class="layui-tab-item">测试1</div>
                            <div class="layui-tab-item">测试2</div>
                        </div>
                    </div>
            </div>
            <div class="layui-input-block" style="min-height: 80px;">
                <button type="button" id="mysubmit" class="pear-btn pear-btn-primary">执行发放</button>
                <!-- <button type="reset" class="pear-btn">重置</button> -->
            </div>
            </form>
        </div>
    </div>
    </div>
    <script>
        layui.use(['form', 'jquery', 'uploads'], function () {
            let form = layui.form;
            let $ = layui.jquery;

            let MODULE_PATH = "{$Request.root}/choujiang.send/";

            $('#mysubmit').click(function () {
                var filepath = $("#filepath").val();
                $.ajax({
                    url: MODULE_PATH + 'index',
                    data: { filepath: filepath },
                    type: 'post',
                    success: function (res) {
                        console.log(res);
                        //判断有没有权限
                        if (res && res.code == 999) {
                            layer.msg(res.msg, {
                                icon: 5,
                                time: 2000,
                            })
                            return false;
                        } else if (res.code == 200) {
                            layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                                parent.layui.table.reload("dataTable");
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                })
            });



            // form.on('radio(type)', function(data){
            //     if(data.value==1){
            //         $("#oss").hide();
            //         $("#qiniu").hide();
            //     }
            //     if(data.value==2){
            //         $("#oss").show();
            //         $("#qiniu").hide();
            //     }
            //     if(data.value==3){
            //         $("#qiniu").show();
            //         $("#oss").hide();
            //     }
            // });  
        })
    </script>
</body>

</html>